
/**
 * @(#)com.book.sys.Test
 * 2009-5-9
 * Copyright 2009
 * Book软件公司, 版权所有 违者必究
 */
package com.site.sys;

 
import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import com.site.core.handle.HandleManager;
import com.site.util.EasyApplicationContextUtils;

/**
 * 平台启动时自动执行该类的init()方法，完成一些初始化的工作
 *
 * @author 陈雄华
 * @version 1.0
 */
public class SysInitializer implements ApplicationContextAware {
    private static boolean isInitialized = false;
    private ApplicationContext ctx;
 
    /*日志记录器*/
    protected Logger log = LoggerFactory.getLogger(this.getClass());

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.ctx = applicationContext;
    }

    @PostConstruct
    private void init() {
        if (isInitialized) {
            return;
        }
        isInitialized = true;
        log.info("init EasyApplicationContextUtils begin.");
        EasyApplicationContextUtils.setApplicationContext(this.ctx);
        log.info("init EasyApplicationContextUtils finish.");
        
        log.info("HandleManager begin.");
        HandleManager.getInstance().init();
        log.info("HandleManager end.");
    }

 
}

